﻿using System;
using Microsoft.FxCop.Sdk;

namespace LINQtoFxCop.Core
{
  /// <summary>
  /// Contains the result data from a rule query
  /// </summary>
  public class QueryResult : IComparable<QueryResult>
  {
    public QueryResult(IComparable value, string fullname, Node node)
    {
      if (node == null)
        throw new ArgumentNullException("node");

      if (value == null)
        Value = string.Empty;
      else
        Value = value;

      Node = node;
      FullName = fullname;

      if (string.IsNullOrEmpty(fullname))
        FullName = ".";

      var index = FullName.LastIndexOf(".") + 1;
      Name = FullName.Substring(index);
    }

    public string FullName
    { get; private set; }
    public string Name
    { get; private set; }
    public IComparable Value
    { get; private set; }
    public Node Node
    { get; private set; }

    #region IComparable<QueryResult> Members

    public int CompareTo(QueryResult other)
    {
      return Value.CompareTo(other.Value);
    }

    #endregion
  }
}
